package edu.bbu.commonproject.backend.db.services;

import edu.bbu.commonproject.backend.db.exceptions.DataBaseErrorException;
import edu.bbu.commonproject.backend.db.exceptions.UserConflictException;
import edu.bbu.commonproject.backend.db.model.DBUser;

/**
 * Interfaces that all UserDAOServices must support.
 */
public interface UserDAOServices
{
	/**
	 * This method inserts a user, in data base.
	 * @param user the user name.
	 * @throws UserConflictException if the user does not exist.
	 * @throws DataBaseErrorException if error occurred in data base.
	 */
	public abstract void insertNewUser(DBUser user) throws UserConflictException, DataBaseErrorException;
	
	/**
	 * This method return the user name. 
	 * @param userName the user name.
	 * @return the user name in data base.
	 * @throws UserConflictException if the user does not exist.
	 * @throws DataBaseErrorException if error occurred in data base.
	 */
	public abstract DBUser getUser(String userName) throws UserConflictException, DataBaseErrorException;
	
	/**
	 * This method check the user name.
	 * @param user the user name in database.
	 * @return true if exists, false but not exists.
	 */
	public abstract boolean isExistingUser(DBUser user);
	
	/**
	 * This method returns user password.
	 * @param user the user name.
	 * @return the password given user name.
	 * @throws UserConflictException if the user does not exist.
	 * @throws DataBaseErrorException if error occurred in data base.
	 */
	public abstract String getPassword(DBUser user) throws UserConflictException, DataBaseErrorException;
	
	/**
	 * Change password for given parameters.
	 * @param user the user name.
	 * @param newPassword the new password.
	 * @throws UserConflictException if the user does not exist.
	 * @throws DataBaseErrorException if error occurred in data base.
	 */
	public abstract void editUserPassword(DBUser user, String newPassword) throws UserConflictException, DataBaseErrorException;
	
	/**
	 * This method delete a user in data base.
	 * @param user the user name.
	 * @throws UserConflictException if the user does not exist.
	 * @throws DataBaseErrorException if error occurred in data base.
	 */
	public abstract void deleteUser(DBUser user) throws UserConflictException, DataBaseErrorException;
}
